/*
 * @Author: ylq
 * @Date: 2022-09-13 11:47:31
 * @Desc: 开发环境配置
 * @Last Modified by: ylq
 * @Last Modified time: 2023-12-12 14:42:08
 */
import { mergeConfig, loadEnv } from 'vite';
import eslint from 'vite-plugin-eslint';
import baseConfig from './vite.config.base';
const config = loadEnv('dev', './'); // 设置第三个参数为 '' 来加载所有环境变量，而不管是否有 `VITE_` 前缀。
const crm = config.VITE_crm;

console.log(13, config, crm);
export default mergeConfig(
  {
    mode: 'development',
    server: {
      open: true,
      fs: {
        strict: true
      },
      port: 3810, //启动端口
      hmr: {
        host: '127.0.0.1',
        port: 3810
      },
      // 设置 https 代理
      proxy: {
        '/api': {
          target: crm,
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, '')
        }
      }
    },
    plugins: [
      eslint({
        cache: false,
        include: ['src/**/*.js', 'src/**/*.vue'],
        exclude: ['node_modules']
      })
    ]
  },
  baseConfig
);
